package com.server;
import java.util.List;

import com.bean.Product;
import com.bean.ServletBean;
import com.bean.User;
import com.server.util.XmlParseHelper;

public class MainServer {

	public static void main(String[] args) {
		//updataQuantity();
		//addNode();
		//getAll();
		
		//startServer();
		
		/*System.out.println(XmlParseHelper.getAll("data.xml", ServletBean.class)
				.toString());*/
		
		startServer();
	}
	
	
	
	/**
	 * 测试查询全部商品
	 */
	private static void getAll() {
		System.out
				.println(XmlParseHelper.getAll("product.xml", Product.class).toString());
	}
	
	/**
	 * 测试增加新商品
	 */
	private static void addNode() {
		Product product = new Product();
		product.setId("1003");
		product.setName("红牛");
		product.setPrice("5.4");
		product.setQuantity("3000");
		product.setCompany("毫升");
		XmlParseHelper.addNode("product.xml", product);
	}
	
	/**
	 * 测试修改产品数量
	 */
	private static void updataQuantity() {
		Product product = new Product();
		product.setId("1002");
		product.setQuantity("1000");
		XmlParseHelper.updataQuantity("product.xml", product);
		List<Product> all = XmlParseHelper.getAll("product.xml", Product.class);
		System.out.println(all);
	}
	
	private static void startServer() {
		SystemServerThread server = new SystemServerThread();
		server.start();
		System.out.println("Server run.");
	}

}
